package io.renren.modules.heartself.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.heartself.entity.ShOrgEntity;
import io.renren.modules.heartself.service.ShOrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 教师表
 *
 * @author jlk
 * @email sunlightcs@gmail.com
 * @date 2021-11-19 05:25:58
 */
@RestController
@RequestMapping("heartSelf/shOrg")
public class ShOrgController {
    @Autowired
    private ShOrgService shOrgService;

    /**
     * 列表
     */
    @GetMapping("/queryOrgList")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = shOrgService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/orgInfo/{orgId}")
    public R info(@PathVariable("orgId") Long orgId) {
        ShOrgEntity shOrg = shOrgService.getById(orgId);

        return R.ok().put("shOrg", shOrg);
    }

    /**
     * 保存
     */
    @PostMapping("/saveOrg")
    public R save(@RequestBody ShOrgEntity shOrg) {
        shOrgService.save(shOrg);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/updateOrg")
    public R update(@RequestBody ShOrgEntity shOrg) {
        shOrgService.updateById(shOrg);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/deleteOrg")
    public R delete(@RequestBody Long[] orgIds) {
        shOrgService.removeByIds(Arrays.asList(orgIds));

        return R.ok();
    }

}
